package com.taobao.home.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.taobao.home.model.po.Process;
import com.taobao.home.model.po.Store;
import com.taobao.home.model.po.StorePreview;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 商品Mapper接口
 */
public interface ProcessMapper extends BaseMapper<Process> {


    @Select("select * from home_process  where  id % #{shardTotal} = #{shardIndex} and (status=1 or status=3) and fail_count<3 limit #{count}")
    List<Process>  selectListByShardIndex(@Param("shardTotal") int shardTotal, @Param("shardIndex") int shardIndex, @Param("count") int count);


    /**
     * 开启一个任务 status=4代表此任务执行中
     * @param processId 任务 process_id
     * @return 更新记录数
     */
    @Update("update home_process set status='4' where (status='1' or status='3') and fail_count<3 and id=#{taskId}")
    int startTask(@Param("taskId") long taskId);




}
